package controller;

import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;

import view.NewWorkoutPlan3;
import view.templates.MyJButton;

public class NewWorkoutPlanListener3 implements ActionListener {

	private Controller controller;
	private NewWorkoutPlan3 newWorkoutPlan;

	public NewWorkoutPlanListener3(Controller controller) {
		this.controller = controller;
	}

	@Override
	public void actionPerformed(ActionEvent e) {
		newWorkoutPlan = controller.getFrame().getNewWorkoutPlan3();

		if (e.getSource().getClass() == MyJButton.class) {
			MyJButton b = (MyJButton) e.getSource();
			if (b == newWorkoutPlan.getNextButton()) {
				if (newWorkoutPlan.showConfirmDialog()) {
					controller.getFrame().initHomeScreen();
				}
			} else if (b == newWorkoutPlan.getReturnButton()) {
				controller.getFrame().initNewWorkoutScreen2();
			} else if (b == newWorkoutPlan.getSaveButton()) {
				newWorkoutPlan.setSaved(true);
				System.err.println("Save");
			} else if (b == newWorkoutPlan.getSaveAndExportButton()) {
				newWorkoutPlan.setSaved(true);
				System.err.println("Save and Export");
			}
		}
	}
}
